#include <jni.h>
#include "CCRender.h"

CCRender ccRender;


extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_opengldemo_GLRender_ndkLoadGLTexTureID(JNIEnv *env, jobject thiz,
                                                          jstring file_name,jint texTureIndex) {

    const char* fileName = env->GetStringUTFChars(file_name,0);
    ccRender.ccTexture.loadTexture(fileName,texTureIndex);
    // 释放资源
    env->ReleaseStringUTFChars(file_name, fileName);
}

extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_opengldemo_GLRender_ndkInitGL(JNIEnv *env, jobject thiz, jobject assets) {
    ccRender.initGL();
    AAssetManager *astManager = AAssetManager_fromJava (env, assets);
    ccRender.ccOpenGlShader.InitShadersFromFile(astManager,"vertex.vert","fragment.frag");
}

extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_opengldemo_GLRender_ndkPaintGL(JNIEnv *env, jobject thiz) {
    ccRender.paintGL();
}
extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_opengldemo_GLRender_ndkResizeGL(JNIEnv *env, jobject thiz, jint width,
                                                   jint height) {
    ccRender.resizeGL(width,height);
}
